package com.ticket.sass.common.entity.tenant;

import com.baomidou.mybatisplus.annotation.*;
import com.ticket.sass.common.entity.tenant.enums.TicketRefundConfigType;
import com.ticket.sass.common.entity.tenant.enums.TicketRefundRuleDurationScope;
import com.ticket.sass.common.entity.tenant.enums.TicketRefundRuleScope;
import com.ticket.sass.common.entity.tenant.enums.TicketRefundRuleStartScope;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import kotlin.Triple;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.function.Function;

/**
 * <p>
 * 退改签配置
 * </p>
 *
 * @author ywb
 * @since 2024-03-06
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("ticket_refund_configs")
@ApiModel(value = "TicketRefundConfigsEntity对象", description = "退改签配置")
public class TicketRefundConfigEntity implements Serializable {
    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "是否启用")
    private Boolean enable;

    @ApiModelProperty(value = "每月可退改次数，-1 无限，> -1 指定次数")
    private Integer max;

    @ApiModelProperty(value = "说明")
    private String instructions;

    @ApiModelProperty(value = "退改类型：1退票，2改签")
    private TicketRefundConfigType type;

    @ApiModelProperty(value = "影院 id")
    private Long cinemaId;

    @ApiModelProperty(value = "租户 id")
    private Long tenantId;

    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    public LocalDateTime createdAt;

    @ApiModelProperty(value = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    public LocalDateTime updatedAt;

    @TableField(select = false)
    @ApiModelProperty(value = "删除时间")
    @TableLogic(value = "null", delval = "now()")
    public LocalDateTime deletedAt;

    @TableField(select = false)
    private List<TicketRefundRuleEntity> rules;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    public Integer getMax() {
        return max;
    }

    public void setMax(Integer max) {
        this.max = max;
    }

    public String getInstructions() {
        return instructions;
    }

    public void setInstructions(String instructions) {
        this.instructions = instructions;
    }

    public TicketRefundConfigType getType() {
        return type;
    }

    public void setType(TicketRefundConfigType type) {
        this.type = type;
    }

    public Long getCinemaId() {
        return cinemaId;
    }

    public void setCinemaId(Long cinemaId) {
        this.cinemaId = cinemaId;
    }

    public Long getTenantId() {
        return tenantId;
    }

    public void setTenantId(Long tenantId) {
        this.tenantId = tenantId;
    }

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }

    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }

    public LocalDateTime getDeletedAt() {
        return deletedAt;
    }

    public void setDeletedAt(LocalDateTime deletedAt) {
        this.deletedAt = deletedAt;
    }

    public List<TicketRefundRuleEntity> getRules() {
        return rules;
    }

    public void setRules(List<TicketRefundRuleEntity> rules) {
        this.rules = rules;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("TicketRefundConfigEntity{");
        sb.append("id=").append(id);
        sb.append(", enable=").append(enable);
        sb.append(", max=").append(max);
        sb.append(", instructions='").append(instructions).append('\'');
        sb.append(", type=").append(type);
        sb.append(", cinemaId=").append(cinemaId);
        sb.append(", tenantId=").append(tenantId);
        sb.append(", createdAt=").append(createdAt);
        sb.append(", updatedAt=").append(updatedAt);
        sb.append(", deletedAt=").append(deletedAt);
        sb.append(", rules=").append(rules);
        sb.append('}');
        return sb.toString();
    }
    public boolean isUnlimitedRefund() {
        return max.equals(-1);
    }
}
